#include "TitleScreenState.h"

#include <iostream>
#include "common_include.h"
using std::cout;


TitleScreenState::TitleScreenState(void) : BaseState()
{
   m_iStateType = STATE_TITLESCREEN;
   m_fTimer = 0.0f;
   m_bUpdateText = true;
}


TitleScreenState::~TitleScreenState(void)
{
}

void TitleScreenState::OnEnter()
{
   // Don't forget to call the base state's function so we get base variables set correctly
   BaseState::OnEnter();

   // Initialize any variables or stuff that needs to be setup on entering this state
   m_fTimer = 0.f;
}

void TitleScreenState::Update(float fTime)
{
   m_fTimer += fTime;

   if (m_fTimer > 0.75f)
   {
      m_fTimer = 0.f;
      m_bUpdateText = true;
   }
}

void TitleScreenState::Render()
{
   static bool bRenderText = true;
   if (m_bUpdateText)
   {
      // This clears the screen
      system("cls");
      cout << "\n\n\n\t\tThis is the title screen\n\n\n";

      // Make this blink/flash on a timer from update
      if (bRenderText)
         cout << "\t\tPress Enter to continue\n";
      bRenderText = !bRenderText;
      m_bUpdateText = false;
   }
}

void TitleScreenState::GetInput()
{
   if (GetAsyncKeyState(VK_RETURN) & 0x81)
   {
      // TODO: replace this with a transition to a more proper state(Main menu or main game state)
      GameManager::GetInstance()->SetGameState(STATE_MAINMENU);
   }
}
